/*      SClassArray.h
 *
 *      Copyright 2009-2010 virpool <virpool@ukrpost.ua>
 *
 *      This program is free software; you can redistribute it and/or modify
 *      it under the terms of the GNU General Public License as published by
 *      the Free Software Foundation; either version 2 of the License, or
 *      (at your option) any later version.
 *
 *      This program is distributed in the hope that it will be useful,
 *      but WITHOUT ANY WARRANTY; without even the implied warranty of
 *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *      GNU General Public License for more details.
 *
 *      You should have received a copy of the GNU General Public License
 *      along with this program; if not, write to the Free Software
 *      Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 *      MA 02110-1301, USA.
 */

#ifndef __SCLASSARRAY_H_
#define __SCLASSARRAY_H_

#include <iostream>
#include <list>
#include "SObject.h"

class SClassArray: public SObject
{
	std::string ar_type;
	unsigned long size;
	unsigned long cur_size;
	list<SObject*> d_value;
	SObject **s_value;

	bool isdynamic;

	static int ToString(SObject*, s_param*, param_list*);
	static int Length(SObject*, s_param*, param_list*);
	static int IsDymanic(SObject*, s_param*, param_list*);
	static int IsStatic(SObject*, s_param*, param_list*);
	static int Add(SObject*, s_param*, param_list*);
	static int Invert(SObject*, s_param*, param_list*);
	static int Sort(SObject*, s_param*, param_list*);
	static int Clear(SObject*, s_param*, param_list*);
	static int Join(SObject*, s_param*, param_list*);

	static char* itoa(int val, int base);
	static int cmpint(const void *a, const void *b);
	static int cmpfloat(const void *a, const void *b);
	static int cmpstring(const void *a, const void *b);
public:
	SClassArray(std::string, bool, S_ARG_TYPES, unsigned long);
	~SClassArray();

	SObject* Get(unsigned long ind);
	void Set(unsigned long ind, SObject *obj);
	std::string GetArrayType() const
	{
		return ar_type;
	}
	
	unsigned long GetSize() const { return cur_size; };
};

#endif /* SCLASSARRAY_H_ */
